home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume19 / df2 / patch01 next >
Encoding:
Internet Message Format  |  1991-04-29  |  5.8 KB

  1. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v19i003:  df2 - an alternate S5R3 df utility, Patch01
  4. Message-ID: <1991Apr30.033349.3181@sparky.IMD.Sterling.COM>
  5. Date: 30 Apr 91 03:33:49 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 180323ab c23d2d77 9b4883fe 9406eb89
  8.  
  9. Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  10. Posting-number: Volume 19, Issue 3
  11. Archive-name: df2/patch01
  12. Patch-To: df2: Volume 18, Issue 81
  13.  
  14. This patch was sent to me by Chip Salzenburg after Paul Slootman
  15. had sent me a port for System 5 Release 4.  It has some advantages
  16. for use in an NFS environment.
  17.  
  18. My goal was to customize a df for my needs and to make the code
  19. available for others to do likewise.  Note my original had just
  20. enough room for MY longest mount directory :-).  In addition, I
  21. have just one more digit in the numeric columns than I need for
  22. blocks and inodes.  80 characters is not a lot of room for the
  23. wide range of stuff you want to print.  We all are likely to
  24. customize.
  25.  
  26. So, with this version and Paul Slootman's R4 port (df2_r4) of the
  27. original, we have a better collection of code and fragments to
  28. each build our idea of a "df -me" dream hack.
  29.  
  30. Chip Salzenberg <chip@tct.com>, <uunet!pdn!tct!chip> says:
  31. >... [O]ur environment (SCO UNIX w/NFS) required a couple of changes to df2.
  32. >
  33. >First, our NFS server (an RS/6000) doesn't report inode stats.
  34. >Second, the pathnames of the NFS directories didn't fit in the column
  35. >constraints.
  36. >
  37. >So I rearranged the columns a bit to leave more space for the mount
  38. >pathname.  (I gained from omitting "/dev/" in the first column.)  Then
  39. >I special-cased NFS filesystems to show the source directory in the
  40. >inode column (since that isn't used for NFS directories anyway).
  41.  
  42. Patches below.  Unshar, patch < df2.p01 and enjoy.
  43.  
  44. #!/bin/sh
  45. # This is a shell archive (shar 3.46)
  46. # made 04/29/1991 17:05 UTC by wht@n4hgf
  47. # Source directory /u1/src/df2
  48. #
  49. # existing files will NOT be overwritten unless -c is specified
  50. #
  51. # This shar contains:
  52. # length  mode       name
  53. # ------ ---------- ------------------------------------------
  54. #   2797 -rw-r--r-- df2.p01
  55. #
  56. # ============= df2.p01 ==============
  57. if test -f 'df2.p01' -a X"$1" != X"-c"; then
  58.     echo 'x - skipping df2.p01 (File already exists)'
  59. else
  60. echo 'x - extracting df2.p01 (Text)'
  61. sed 's/^X//' << 'SHAR_EOF' > 'df2.p01' &&
  62. XIndex: df2.c
  63. X***************
  64. X*** 13,16 ****
  65. X--- 13,17 ----
  66. X  #include <sys/stat.h>
  67. X  #include <sys/statfs.h>
  68. X+ #include <sys/fstyp.h>
  69. X  #include <mnttab.h>
  70. X  
  71. X***************
  72. X*** 21,25 ****
  73. X  {
  74. X  "                                   Size (kb)                  Inodes        ",
  75. X! "Filesystem|Mount Dir    | Total   Free    Used   Used| Total  Free  Used   Used",
  76. X  (char *)0
  77. X  };
  78. X--- 22,26 ----
  79. X  {
  80. X  "                                   Size (kb)                  Inodes        ",
  81. X! "Filsys|Mount Dir      |  Total    Free    Used Used | Total   Free   Used Used",
  82. X  (char *)0
  83. X  };
  84. X***************
  85. X*** 26,30 ****
  86. X  
  87. X  char *sep =
  88. X! "----------+-------------+----------------------------+-------------------------";
  89. X  
  90. X  /*+-------------------------------------------------------------------------
  91. X--- 27,31 ----
  92. X  
  93. X  char *sep =
  94. X! "------+---------------+-----------------------------+-------------------------";
  95. X  
  96. X  /*+-------------------------------------------------------------------------
  97. X***************
  98. X*** 42,45 ****
  99. X--- 43,47 ----
  100. X  struct statfs statf_buf;
  101. X  struct statfs *fs = &statf_buf;
  102. X+ int fstyp_nfs = sysfs(GETFSIND, "NFS");
  103. X  
  104. X  long kb_size;
  105. X***************
  106. X*** 71,74 ****
  107. X--- 73,78 ----
  108. X      while(fread((char *)mt,1,sizeof(*mt),fpmt) == sizeof(*mt))
  109. X      {
  110. X+         char *dev;
  111. X+ 
  112. X          if(statfs(mt->mt_filsys,fs,sizeof(*fs),0))
  113. X          {
  114. X***************
  115. X*** 85,94 ****
  116. X          ino_free = fs->f_ffree;
  117. X          ino_used = ino_size - ino_free;
  118. X!         ino_used_pct = (ino_used * 100) / ino_size;
  119. X  
  120. X!         printf("%-10.10s|%-13.13s|%7ld %7ld %7ld %3d%%|%6ld %6ld %6ld %3d%%\n",
  121. X!             mt->mt_dev,mt->mt_filsys,
  122. X!             kb_size,kb_free,kb_used,kb_used_pct,
  123. X!             ino_size,ino_free,ino_used,ino_used_pct);
  124. X  
  125. X          kb_size_total  += kb_size;
  126. X--- 89,111 ----
  127. X          ino_free = fs->f_ffree;
  128. X          ino_used = ino_size - ino_free;
  129. X!         ino_used_pct = ino_size ? ((ino_used * 100) / ino_size) : 0;
  130. X  
  131. X!         dev = (fs->f_fstyp == fstyp_nfs) ? "NFS"
  132. X!             : (strncmp(mt->mt_dev, "/dev/", 5) == 0) ? mt->mt_dev + 5
  133. X!             : mt->mt_dev;
  134. X! 
  135. X!         printf("%-6.6s|%-15.15s|%7ld %7ld %7ld %3d%% |",
  136. X!                dev, mt->mt_filsys,
  137. X!                kb_size,kb_free,kb_used,kb_used_pct);
  138. X!         if (fs->f_fstyp == fstyp_nfs)
  139. X!         {
  140. X!             printf(" [%s]", mt->mt_dev);
  141. X!         }
  142. X!         else if (ino_size)
  143. X!         {
  144. X!             printf("%6ld %6ld %6ld %3d%%",
  145. X!                    ino_size,ino_free,ino_used,ino_used_pct);
  146. X!         }
  147. X!         printf("\n");
  148. X  
  149. X          kb_size_total  += kb_size;
  150. X***************
  151. X*** 105,109 ****
  152. X  
  153. X      printf("%s\n",sep);
  154. X!     printf("%-10.10s|%-13.13s|%7ld %7ld %7ld %3d%%|%6ld %6ld %6ld %3d%%\n",
  155. X          "","total",
  156. X          kb_size_total,kb_free_total,kb_used_total,kb_used_pct,
  157. X--- 122,126 ----
  158. X  
  159. X      printf("%s\n",sep);
  160. X!     printf("%-6.6s|%-15.15s|%7ld %7ld %7ld %3d%% |%6ld %6ld %6ld %3d%%\n",
  161. X          "","total",
  162. X          kb_size_total,kb_free_total,kb_used_total,kb_used_pct,
  163. X
  164. SHAR_EOF
  165. chmod 0644 df2.p01 ||
  166. echo 'restore of df2.p01 failed'
  167. Wc_c="`wc -c < 'df2.p01'`"
  168. test 2797 -eq "$Wc_c" ||
  169.     echo 'df2.p01: original size 2797, current size' "$Wc_c"
  170. fi
  171. exit 0
  172.  
  173. ----------------------------------------------------------------------------
  174. Warren Tucker                     emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  175. "I was 35 years old before I knew a pie was meant to be eaten." - Moe Howard
  176.  
  177. exit 0 # Just in case...
  178. -- 
  179. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  180. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  181. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  182. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  183.